<?php
/**
 * 应用仓库
 * @author wangwx 2015-5-13
 */

namespace common\repositories\common;

use common\entities\common\MyscrmAuthorizeTypeEntity;
use common\repositories\BaseRepository;
use common\entities\common\MyscrmApplicationEntity;
use yii\helpers\ArrayHelper;

class MyscrmApplicationRepository extends BaseRepository {
	
	/**
	 * 根据应用id,获取应用对象
	 * @param string $applicationId 应用id
	 * @return MyscrmApplicationEntity
	 */
	public static function getApplicationByApplicationId($applicationId) {
		return MyscrmApplicationEntity::getApplicationByApplicationId($applicationId);
	}

	/**
	 * 获取所有应用
	 * @return array|MyscrmApplicationEntity[]
	 */
	public function getAll()
	{
		$authTypeList = MyscrmAuthorizeTypeEntity::find()->all();
		$applicationIdList = ArrayHelper::getColumn($authTypeList, 'ApplicationId');
		return MyscrmApplicationEntity::findAll(['ApplicationId' => $applicationIdList]);
	}

	
}

